/*
  (C) 2005 Adam D. Bradley

  This program is free software; you can redistribute it and/or
  modify it under the terms of Version 2 of the GNU General Public 
  License.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

package step;

import java.net.URI;
import java.util.ArrayList;

import step.exceptions.STEPException;

public class SenderGetSocketNode extends SenderSocketNode
{
	public SenderGetSocketNode(String id, 
				   String targetID, URI targetURI) {
		super(id, targetID, targetURI);
	}
	
	public SenderGetSocketNode(String targetID, URI targetURI) {
		super(targetID, targetURI);
	}

	public String GetInfoXML() { 
		return super.GetInfoXML("GET", "sender", TargetURI); 
	}
	
	public boolean IsEnabled() {
		return HasFreshInput(0);
	}

	/* The work is done by GET for us. */

	protected void Evaluate() throws EvaluationFailure {
		rt_evaluated = true;
		SetValue(GetInput(0));
	}

	public void Write(java.io.OutputStream out, int depth) throws java.io.IOException {
		WriteBasis(out, depth, "type=\"sender\" method=\"get\" " + 
			   "targetid=\"" + TargetID + "\" " + 
			   "targeturi=\"" + TargetURI + "\"");
	}

	@Override
	public void validate(Graph g, ArrayList<STEPException> compilationErrors) {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public Node ShallowCopy() {
		SenderGetSocketNode cn = new SenderGetSocketNode(ID, TargetID, TargetURI);
		Node.CopyNonRTPropertiesFromAtoB(this,cn);
		return cn;
	}
}
